package com.just521.xinshoutong.listadapter;

import java.util.List;

import android.content.Context;
import android.view.InflateException;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.just521.xinshoutong.R;
import com.just521.xinshoutong.http.ImageDownLoader;
import com.just521.xinshoutong.json.MainList_SummaryRec;
import com.just521.xinshoutong.json.TagList_Rec;


public class MainTagListAdapter<T> extends ListAdapter_base
{
	class ViewHolder{
		TextView name;
		TextView notecount;
		ImageView lockflag;
	}
	
	private ImageDownLoader asyncImageLoader;
	private	ListView		mList=null;
	
	public MainTagListAdapter(Context c,List<T> list, ListView lv )
	{	
		super(c,list);
		mList = lv;
		asyncImageLoader = new ImageDownLoader();
	}
	
	
	protected View initView(ViewGroup parent){
		View retV=null;
		try{
			retV = mfactory.inflate(R.layout.main_taglist_item,parent, false);
			ViewHolder temp = new ViewHolder();
			temp.name=(TextView)retV.findViewById(R.id.tag_name);
			temp.notecount=(TextView)retV.findViewById(R.id.tag_notecount);
			temp.lockflag = (ImageView)retV.findViewById(R.id.tag_lock);
			retV.setTag(temp);
		}catch(InflateException e){
		}
		return retV;
	}
	
	protected void setContent(View retV,Object content,int pos){
		
		ViewHolder temp = (ViewHolder)retV.getTag();
		TagList_Rec rec=(TagList_Rec)content;
		temp.name.setText(rec.getName());
		if(rec.isIsencode()){
			temp.lockflag.setVisibility(View.VISIBLE);
			temp.notecount.setVisibility(View.GONE);
		}else{
			temp.notecount.setVisibility(View.VISIBLE);
			temp.notecount.setText("("+String.valueOf(rec.getNotecount())+")");
			temp.lockflag.setVisibility(View.GONE);
		}
       
        
	}
	


}
